using System;
using System.Data.SqlClient;

public enum PsSpecHistoryChangeType
{
    Project,
    Noun,
    Cmdlet,
    CmdletParameter,
    ParameterSetEntry
}

public enum PsSpecHistoryChangeAction
{
    Add,
    Change,
    Remove
}

/// <summary>
/// A class that represents a spec history item
/// </summary>
public class PsSpecHistoryEntry : IPsSpecDataReader
{
    public PsSpecHistoryEntry() { }

    public void Initialize(SqlDataReader reader, System.Collections.Generic.Dictionary<string, Int32> columnMappings)
    {
        this.specHistoryId = reader.GetInt32(columnMappings["Id"]);
        this.changeType = (PsSpecHistoryChangeType)Enum.Parse(typeof(PsSpecHistoryChangeType), reader[columnMappings["ChangeType"]] as string);
        this.lastUpdated = reader.GetDateTime(columnMappings["LastUpdated"]);
        this.changedBy = reader[columnMappings["ChangedBy"]] as string;
        this.projectId = reader.GetInt32(columnMappings["ProjectId"]);
        this.projectName = reader[columnMappings["ProjectName"]] as string;
        this.cmdletId = reader.GetInt32(columnMappings["CmdletId"]);
        this.cmdletName = reader[columnMappings["CmdletName"]] as string;
        this.parameterId = reader.GetInt32(columnMappings["ParameterId"]);
        this.parameterName = reader[columnMappings["ParameterName"]] as string;
        this.action = (PsSpecHistoryChangeAction)Enum.Parse(typeof(PsSpecHistoryChangeAction), reader[columnMappings["Action"]] as string);
        this.propertyName = reader[columnMappings["PropertyName"]] as string;
        this.oldValue = reader[columnMappings["OldValue"]] as string;
        this.newValue = reader[columnMappings["NewValue"]] as string;
        this.notes = reader[columnMappings["Notes"]] as string;
    }

    public int Id
    {
        get { return specHistoryId; }
        set { specHistoryId = value; }
    }
    private int specHistoryId;

    public PsSpecHistoryChangeType ChangeType
    {
        get { return changeType; }
        set { changeType = value; }
    }
    private PsSpecHistoryChangeType changeType;

    public DateTime LastUpdated
    {
        get { return lastUpdated; }
        set { lastUpdated = value; }
    }
    private DateTime lastUpdated;

    public string ChangedBy
    {
        get { return changedBy; }
        set { changedBy = value; }
    }
    private string changedBy;

    public int ProjectId
    {
        get { return projectId; }
        set { projectId = value; }
    }
    private int projectId;

    public string ProjectName
    {
        get { return projectName; }
        set { projectName = value; }
    }
    private string projectName;

    public int CmdletId
    {
        get { return cmdletId; }
        set { cmdletId = value; }
    }
    private int cmdletId;

    public string CmdletName
    {
        get { return cmdletName; }
        set { cmdletName = value; }
    }
    private string cmdletName;

    public int ParameterId
    {
        get { return parameterId; }
        set { parameterId = value; }
    }
    private int parameterId;

    public string ParameterName
    {
        get { return parameterName; }
        set { parameterName = value; }
    }
    private string parameterName;

    public PsSpecHistoryChangeAction Action
    {
        get { return action; }
        set { action = value; }
    }
    private PsSpecHistoryChangeAction action;

    public string PropertyName
    {
        get { return propertyName; }
        set { propertyName = value; }
    }
    private string propertyName;

    public string OldValue
    {
        get { return oldValue; }
        set { oldValue = value; }
    }
    private string oldValue;

    public string NewValue
    {
        get { return newValue; }
        set { newValue = value; }
    }
    private string newValue;

    public string Notes
    {
        get { return notes; }
        set { notes = value; }
    }
    private string notes;
}
